//
//  StatusCellBottomView.swift
//  HMWeibo
//
//  Created by wulei on 15/12/11.
//  Copyright © 2015年 wulei. All rights reserved.
//

import UIKit

class StatusCellBottomView: UIView {
 /// 构造函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    
// MARK: - 懒加载控件
    private lazy var retweetedButton: UIButton = UIButton(title: " 转发", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_retweet")
    private lazy var commentButton: UIButton = UIButton(title: " 评论", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_comment")
    private lazy var likeButton: UIButton = UIButton(title: " 赞", fontSize: 12, color: UIColor.darkGrayColor(), imageName: "timeline_icon_unlike")
    
}


// MARK: - 设置界面
extension StatusCellBottomView {
    
    // 设置控件
    private func setupUI() {
        // 设置背景颜色
        backgroundColor = UIColor.redColor()
        
        // 添加控件
        addSubview(retweetedButton)
        addSubview(commentButton)
        addSubview(likeButton)
        
        let V1 = setView()
        let V2 = setView()
        addSubview(V1)
        addSubview(V2)
        
        // 设置约束
        // 转发按钮
        retweetedButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(self.snp_top)
            make.left.equalTo(self.snp_left)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        // 评论按钮
        commentButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(retweetedButton.snp_top)
            make.left.equalTo(retweetedButton.snp_right)
            make.width.equalTo(retweetedButton.snp_width)
            make.height.equalTo(retweetedButton.snp_height)


        }
        
        // 点赞按钮
        likeButton.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commentButton.snp_top)
            make.left.equalTo(commentButton.snp_right)
            make.width.equalTo(commentButton.snp_width)
            make.height.equalTo(commentButton.snp_height)

            

            make.right.equalTo(self.snp_right)
        }
        
        // 设置分隔视图的Frame
        let w = 0.4
        let scale = 0.6
        
        
        V1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.centerY.equalTo(retweetedButton.snp_centerY)
            make.width.equalTo(w)
            make.height.equalTo(retweetedButton.snp_height).multipliedBy(scale)
        }
        
        V2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.centerY.equalTo(commentButton.snp_centerY)
            make.width.equalTo(w)
            make.height.equalTo(commentButton.snp_height).multipliedBy(scale)
        }
        
        
        
    }
    
    
    // 创建分隔视图
    private func setView()-> UIView {
        let V1 = UIView()
        V1.backgroundColor = UIColor.darkGrayColor()
        
        return V1
        
    }
    
    
    
    
    
}
